# load libraries and clear workspace
library("smacof")
library("rgl")
rm(list = ls())
This experiment created 24 speech samples that contained varying degrees of distortion, the kind produced by hearing aids. There were eight levels of distortion and three different kinds of distortion. All possible pairs of the 24 sounds were presented (276 pairs): the listeners chose the stimulus of the pair that had the better sound quality. The data file contains the preferences across stimuli in the columns, higher numbers mean less preference. The data are the number of times each sample sound was not chosen over the other 23 distortion-level conditions. Larger numbers correspond to lower preferences for that stimulus. There were 32 listeners: 14 with normal hearing and 18 were hearing-impaired. The data are arranged in a 32 listeners by 24 speech samples matrix.
Arehart, K. H., Kates, J. M., Anderson, M. C., & Harvey, L. O., Jr. (2007). Effects of noise and distortion on speech quality judgments in normal-hearing and hearing-impaired listeners. Journal of the Acoustical Society of America, 122(2), 1150–1164.
fn <- "pref data arehart.csv"
df <- read.csv(fn, header = TRUE)
# make row names equal to the subject ID column
row.names(df) <- df$subj
# get rid of the subject ID column
df$subj <- NULL
mod2D <- smacofRect(df, ndim = 2, itmax = 10000)
mod3D <- smacofRect(df, ndim = 3, itmax = 10000)
mod4D <- smacofRect(df, ndim = 4, itmax = 10000)
mod5D <- smacofRect(df, ndim = 5, itmax = 10000)
mod6D <- smacofRect(df, ndim = 6, itmax = 30000)
mod7D <- smacofRect(df, ndim = 7, itmax = 30000)
mod2D
##
## Call: smacofRect(delta = df, ndim = 2, itmax = 10000)
##
## Model: Rectangular smacof
## Number of subjects: 32
## Number of objects: 24
##
## Stress-1 value: 0.089
## Number of iterations: 2859
mod3D
##
## Call: smacofRect(delta = df, ndim = 3, itmax = 10000)
##
## Model: Rectangular smacof
## Number of subjects: 32
## Number of objects: 24
##
## Stress-1 value: 0.081
## Number of iterations: 2699
The stress of the 2D solution is 0.089. The stress of the 3D solution is 0.0814.
x <- paste(2:7, "D", sep = "")
y <- c(mod2D$stress, mod3D$stress, mod4D$stress, mod5D$stress, mod6D$stress, mod7D$stress)
barplot(y, names.arg = x,
xlab = "Dimensionality of Space",
ylab = "Stress-1")
In these plots both the ojects (sound stimuli) and the subjects are plotted in the same space. The objects are in teal and the subjects in pink. The eight sounds with the same type of distortion are connected by lines, running from least to most distortion.
plot.2D <- function(){
# make plot square'
# 2D solution plot
par(pty = "s", mfcol = (c(1, 2)))
mxplt <- max(abs(max(mod2D$conf.row, mod2D$conf.col)),
abs(min(mod2D$conf.row, mod2D$conf.col))) * 1.1
plot(mod2D, joint = TRUE,
xlim = c(-mxplt, mxplt),
ylim = c(-mxplt, mxplt),
main = "2D Solution")
lines(mod2D$conf.col[1:8, ])
lines(mod2D$conf.col[9:16, ])
lines(mod2D$conf.col[17:24,])
# Dimensions 1 and 2 of 3D solution
mxplt <- max(abs(max(mod3D$conf.row, mod3D$conf.col)),
abs(min(mod3D$conf.row, mod3D$conf.col))) * 1.1
plot(mod3D, joint = TRUE,
xlim = c(-mxplt, mxplt),
ylim = c(-mxplt, mxplt),
main = "3D Solution")
lines(mod3D$conf.col[1:8, ])
lines(mod3D$conf.col[9:16, ])
lines(mod3D$conf.col[17:24,])
par(pty = "m", mfcol = (c(1, 1)))
}
plot.2D()
In these plots both the ojects (sound stimuli) and the subjects are plotted in the same space. The objects are in red. The normal-hearing subjects are blue; the hearing-impaired are green. Note that the dispersion of the hearing impaired ssubjects’ ideal points is greater than the normal-hearing subjects. The eight sounds with the same type of distortion are connected by lines, running from least to most distortion. Zoom in on the center of the space to see how the ideal points of the subjects cluster around the stimuli with least distortion.
plot.3D <- function() {
mxplt <- max(abs(max(mod3D$conf.row, mod3D$conf.col)), abs(min(mod3D$conf.row, mod3D$conf.col))) * 1.1
plot3d(mod3D$conf.col, col = "red",
type = "s",
radius = .8,
xlim = c(-mxplt, mxplt),
ylim = c(-mxplt, mxplt),
zlim = c(-mxplt, mxplt))
text3d(mod3D$conf.col,
text = rownames(mod3D$conf.col),
cex = 0.7,
adj = c(1.6, 1.6))
# add the subjects' ideal points
plot3d(mod3D$conf.row,
col = c(rep("blue", 14), rep("green", 18)),
add = TRUE,
type = "s",
radius = 0.6)
text3d(mod3D$conf.row,
text = rownames(mod3D$conf.row),
cex = 0.5,
adj = c(1.5, 1.5))
lines3d(mod3D$conf.col[1:8, ])
lines3d(mod3D$conf.col[9:16, ])
lines3d(mod3D$conf.col[17:24,])
}
plot.3D()